/*
 * @Description  :
 * @Author       : YiDing Xue
 * @Date         : 2023-01-12
 * @LastEditors  : YiDing Xue
 * @LastEditTime : 2023-02-01
 */
const baseTitle = import.meta.env.VITE_TITLE

export const createPageTitleGuard = router => {
  router.afterEach(to => {
    const pageTitle = to.meta?.title
    if (pageTitle) {
      document.title = `${pageTitle} | ${baseTitle}`
    } else {
      document.title = baseTitle
    }
  })
}
